﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using SIS.ENT;
using SIS.BLL;

/// <summary>
/// Summary description for Common
/// </summary>
/// 
namespace SIS.UI
{
    public class Common
    {
        public Common()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public void LoadNoOfSibling(DropDownList ddlNoOfSibling, string SelectItem)
        {
            ddlNoOfSibling.Items.Clear();

            for (int i = 0; i <= 20; i++)
            {
                ddlNoOfSibling.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }

            if (!SelectItem.Equals(string.Empty))
            {
                ddlNoOfSibling.SelectedValue = SelectItem;
            }
        }

        public void LoadRelationshipTypeDDL(DropDownList ddlRelationship, string SelectItem)
        {
            RelationshipTypeCodeTableList lList = new RelationshipTypeCodeTableList();
            lList = RelationshipTypeCodeTableManager.GetList();

            ddlRelationship.DataSource = lList;
            ddlRelationship.DataTextField = "Description";
            ddlRelationship.DataValueField = "RelationshipTypeCode";
            ddlRelationship.DataBind();

            if (!SelectItem.Equals(string.Empty))
            {
                ddlRelationship.SelectedValue = SelectItem;
            }
        }

        public void LoadSpeakLanguageDDL(DropDownList ddlLanguage, string SelectItem)
        {
            SpeakLanguageCodeTableList lList = new SpeakLanguageCodeTableList();
            lList = SpeakLanguageCodeTableManager.GetList();

            ddlLanguage.DataSource = lList;
            ddlLanguage.DataTextField = "Description";
            ddlLanguage.DataValueField = "SpeakLanguageCode";
            ddlLanguage.DataBind();

            if (!SelectItem.Equals(string.Empty))
            {
                ddlLanguage.SelectedValue = SelectItem;
            }
        }

        public void LoadParentStatusDDL(DropDownList ddlParentStatus, string SelectItem)
        {
            ParentStatusCodeTableList lList = new ParentStatusCodeTableList();
            lList = ParentStatusCodeTableManager.GetList();

            if (lList.Count > 0)
            {
                ddlParentStatus.DataSource = lList;
                ddlParentStatus.DataTextField = "Description";
                ddlParentStatus.DataValueField = "ParentStatusCode";
                ddlParentStatus.DataBind();
            }
            

            if (!SelectItem.Equals(string.Empty))
            {
                ddlParentStatus.SelectedValue = SelectItem;
            }
        }

        public void LoadTravelDocDDL(DropDownList ddlTravelDocType,string SelectItem)
        {

            TravelDocumentTypeCodeTableList lList = new TravelDocumentTypeCodeTableList();
            lList = TravelDocumentTypeCodeTableManager.GetList();

            ddlTravelDocType.DataSource = lList;
            ddlTravelDocType.DataTextField = "Description";
            ddlTravelDocType.DataValueField = "TravelDocTypeCode"; 
            ddlTravelDocType.DataBind();

            if (SelectItem.Equals(string.Empty))
            {
                ddlTravelDocType.SelectedValue = SelectItem;
            }
        }

        public void LoadNationalityDDL(DropDownList ddlNationality, string SelectItem)
        {
            NationalityCodeTableList lList = new NationalityCodeTableList();
            lList = NationalityCodeTableManager.GetList();

            ddlNationality.DataSource = lList;
            ddlNationality.DataTextField = "Description";
            ddlNationality.DataValueField = "NationalityCode"; 
            ddlNationality.DataBind();

            if (SelectItem.Equals(string.Empty))
            {
                ddlNationality.SelectedValue = SelectItem;
            }
        }

        public void LoadDrivingLicenseTypeDDL(DropDownList ddlDrivingLicenseType, string SelectItem)
        {
            DrivingLicenceTypeTableList lList = new DrivingLicenceTypeTableList();
            lList = DrivingLicenceTypeTableManager.GetList();

            ddlDrivingLicenseType.DataSource = lList;
            ddlDrivingLicenseType.DataTextField = "Description";
            ddlDrivingLicenseType.DataValueField = "DrivingLicenceTypeCode";
            ddlDrivingLicenseType.DataBind();
            

            if (SelectItem.Equals(string.Empty))
            {
                ddlDrivingLicenseType.SelectedValue = SelectItem;
            }
        }

        public void LoadBloodGroupDDL(DropDownList ddlBloodGroupCode, string SelectItem)
        {
            BloodGroupCodeTableList lList = new BloodGroupCodeTableList();
            lList = BloodGroupCodeTableManager.GetList();

            ddlBloodGroupCode.DataSource = lList;
            ddlBloodGroupCode.DataTextField = "Description";
            ddlBloodGroupCode.DataValueField = "BloodGroupCode"; 
            ddlBloodGroupCode.DataBind();

            if (SelectItem.Equals(string.Empty))
            {
                ddlBloodGroupCode.SelectedValue = SelectItem;
            }
        }

        public void LoadMartialStatusCodeDDL(DropDownList ddlMartialStatusCode, string SelectItem)
        {
            MaritalStatusCodeTableList lList = new MaritalStatusCodeTableList();
            lList = MaritalStatusCodeTableManager.GetList();

            ddlMartialStatusCode.DataSource = lList;
            ddlMartialStatusCode.DataTextField = "Description";
            ddlMartialStatusCode.DataValueField = "MaritalStatusCode";
            ddlMartialStatusCode.DataBind();

            if (SelectItem.Equals(string.Empty))
            {
                ddlMartialStatusCode.SelectedValue = SelectItem;
            }
        }

        public void LoadRaceCodeDDL(DropDownList ddlRaceGroupCode, string SelectItem)
        {
            RaceCodeTableList lList = new RaceCodeTableList();
            lList = RaceCodeTableManager.GetList();

            ddlRaceGroupCode.DataSource = lList;
            ddlRaceGroupCode.DataTextField = "Description";
            ddlRaceGroupCode.DataValueField = "RaceCode";
            ddlRaceGroupCode.DataBind();

            if (SelectItem.Equals(string.Empty))
            {
                ddlRaceGroupCode.SelectedValue = SelectItem;
            }
        }

        public void LoadReligionCodeDDL(DropDownList ddlReligionCodeCode, string SelectItem)
        {
            ReligionCodeTableList lList = new ReligionCodeTableList();
            lList = ReligionCodeTableManager.GetList();

            ddlReligionCodeCode.DataSource = lList;
            ddlReligionCodeCode.DataTextField = "Description";
            ddlReligionCodeCode.DataValueField = "ReligionCode";
            ddlReligionCodeCode.DataBind();

            if (SelectItem.Equals(string.Empty))
            {
                ddlReligionCodeCode.SelectedValue = SelectItem;
            }
        }

        public void LoadCountryCodeDDL(DropDownList ddlCountryCodeCode, string SelectItem)
        {
            CountryCodeTableList lList = new CountryCodeTableList();
            lList = CountryCodeTableManager.GetList();

            if (lList.Count > 0)
            {
                ddlCountryCodeCode.DataSource = lList;
                ddlCountryCodeCode.DataTextField = "CountryName";
                ddlCountryCodeCode.DataValueField = "CountryCode";
                ddlCountryCodeCode.DataBind();
            }
            else
            {
                ddlCountryCodeCode.DataSource = null;
                ddlCountryCodeCode.Items.Clear();
                ddlCountryCodeCode.Items.Add(new ListItem("Select", "-1"));
            }
            //if (SelectItem.Equals(string.Empty))
            //{
            //    ddlCountryCodeCode.SelectedValue = SelectItem;
            //}
        }

        public void LoadDistrictCodeDDL(DropDownList ddlDistrictCodeCode,Int16 CountryCode, string SelectItem)
        {
            DistrictCodeTableList lList = new DistrictCodeTableList();
            lList = DistrictCodeTableManager.GetList(CountryCode);

            if (lList.Count > 0)
            {
                ddlDistrictCodeCode.DataSource = lList;
                ddlDistrictCodeCode.DataTextField = "DistrictName";
                ddlDistrictCodeCode.DataValueField = "DistrictCode";
                ddlDistrictCodeCode.DataBind();
            }
            else
            {
                ddlDistrictCodeCode.DataSource = null;
                ddlDistrictCodeCode.Items.Clear();
                ddlDistrictCodeCode.Items.Add(new ListItem("Select", "-1"));
            }

            
            //if (SelectItem.Equals(string.Empty))
            //{
            //    ddlDistinctCodeCode.SelectedValue = SelectItem;
            //}

        }

        public void LoadCityCodeDDL(DropDownList ddlCityCodeCode,Int32 DistinctCode , Int16 CountryCode, string SelectItem)
        {
            CityCodeTableList lList = new CityCodeTableList();
            lList = CityCodeTableManager.GetList(DistinctCode,CountryCode);
            ddlCityCodeCode.DataSource = null;
            if (lList.Count > 0)
            {
                ddlCityCodeCode.DataSource = lList;
                ddlCityCodeCode.DataTextField = "CityName";
                ddlCityCodeCode.DataValueField = "CityCode";
                ddlCityCodeCode.DataBind();
            }
            else
            {
                ddlCityCodeCode.DataSource = null;
                ddlCityCodeCode.Items.Clear();
                ddlCityCodeCode.Items.Add(new ListItem("Select", "-1"));
            }
            
            //if (SelectItem.Equals(string.Empty))
            //{
            //    ddlCityCodeCode.SelectedValue = SelectItem;
            //}
        }

        public void LoadDesignationCodeDDL(DropDownList ddlDesignationCodeCode, string SelectItem)
        {
            JobDesignationCodeTableList lList = new JobDesignationCodeTableList();
            lList = JobDesignationCodeTableManager.GetList();

            ddlDesignationCodeCode.DataSource = lList;
            ddlDesignationCodeCode.DataTextField = "Description";
            ddlDesignationCodeCode.DataValueField = "JobDesignationCode";
            ddlDesignationCodeCode.DataBind();

             
        }

        public void LoadCurrencyCodeDDL(DropDownList ddlCurrencyCodeCode, string SelectItem)
        {
            CurrencyCodeTableList lList = new CurrencyCodeTableList();
            lList = CurrencyCodeTableManager.GetList();

            ddlCurrencyCodeCode.DataSource = lList;
            ddlCurrencyCodeCode.DataTextField = "CurrencyCode";
            ddlCurrencyCodeCode.DataValueField = "CurrencyCodeKey"; 
            ddlCurrencyCodeCode.DataBind();


        }

        public void LoadPaymentTypeCodeCodeDDL(DropDownList ddlPaymentTypeCodeCode, string SelectItem)
        {
            PaymentTypeCodeTableList lList = new PaymentTypeCodeTableList();
            lList = PaymentTypeCodeTableManager.GetList();

            ddlPaymentTypeCodeCode.DataSource = lList;
            ddlPaymentTypeCodeCode.DataTextField = "Description";
            ddlPaymentTypeCodeCode.DataValueField = "PaymentTypeCode";
            ddlPaymentTypeCodeCode.DataBind();


        }

        public void LoadCategoryTypeCodeCodeDDL(DropDownList ddlCategoryTypeCodeCode, string SelectItem)
        {
            CategoryTypeCodeTableList lList = new CategoryTypeCodeTableList();
            lList = CategoryTypeCodeTableManager.GetList();

            ddlCategoryTypeCodeCode.DataSource = lList;
            ddlCategoryTypeCodeCode.DataTextField = "Description";
            ddlCategoryTypeCodeCode.DataValueField = "CategoryTypeCode";
            ddlCategoryTypeCodeCode.DataBind();


        }

        public void LoadCurrencyDDL(DropDownList ddlCurrencyCodeCode, string SelectItem)
        {
            CurrencyCodeTableList lList = new CurrencyCodeTableList();
            lList = CurrencyCodeTableManager.GetList();

            ddlCurrencyCodeCode.DataSource = lList;
            ddlCurrencyCodeCode.DataTextField = "Description";
            ddlCurrencyCodeCode.DataValueField = "CurrencyCode";
            ddlCurrencyCodeCode.DataBind();


        }

        //public void LoadDistrictCodeDDL(DropDownList ddlDistinctCodeCode, string SelectItem)
        //{
        //    DistrictCodeTableList lList = new DistrictCodeTableList();
        //    lList = DistrictCodeTableManager.GetList();

        //    ddlDistinctCodeCode.DataSource = lList;
        //    ddlDistinctCodeCode.DataTextField = "DistrictName";
        //    ddlDistinctCodeCode.DataValueField = "DistrictCode";
        //    ddlDistinctCodeCode.DataBind();

        //}

        public void LoadTeacherDDL(DropDownList ddlTeacher, int SchoolKey, string SelectItem)
        {
            TeacherProfileTableList lList = new TeacherProfileTableList();
            lList = TeacherProfileTableManager.GetList(SchoolKey);

            ddlTeacher.DataSource = lList;
            ddlTeacher.DataTextField = "Teacher";
            ddlTeacher.DataValueField = "UserAccountKey";
            ddlTeacher.DataBind();


        }

        public void LoadTeacherByKeyDDL(DropDownList ddlTeacher, int SchoolKey, string SelectItem)
        {
            TeacherProfileTableList lList = new TeacherProfileTableList();
            lList = TeacherProfileTableManager.GetList(SchoolKey);

            ddlTeacher.DataSource = lList;
            ddlTeacher.DataTextField = "Teacher";
            ddlTeacher.DataValueField = "TeacherProfileKey";
            ddlTeacher.DataBind();


        }

        public void LoadEmployeeDDL(DropDownList ddlEmployee, int SchoolKey, string SelectItem)
        {
            EmployeeProfileTableList lList = new EmployeeProfileTableList();
            lList = EmployeeProfileTableManager.GetList(SchoolKey);

            ddlEmployee.DataSource = lList;
            ddlEmployee.DataTextField = "Employee";
            ddlEmployee.DataValueField = "UserAccountKey";
            ddlEmployee.DataBind();


        }

        public void LoadEmployeeDDLWithBlank(DropDownList ddlEmployee, int SchoolKey, string SelectItem)
        {

            EmployeeProfileTableList lList = new EmployeeProfileTableList();
            lList = EmployeeProfileTableManager.GetList(SchoolKey);
            ListItem Defaultltm = new ListItem();
            Defaultltm.Text = "-- Select Employee --";
            Defaultltm.Value = "0";
            ddlEmployee.Items.Add(Defaultltm);

            foreach (EmployeeProfileTable item in lList)
            {
                ListItem ltm = new ListItem();

                ltm.Text = item.Employee;
                ltm.Value = Convert.ToString(item.EmployeeProfileKey);
                ddlEmployee.Items.Add(ltm);
            }


        }


        public void LoadSchoolDDL(DropDownList ddlSchool, string selectedItem)
        {
            SchoolProfileTableList lList = new SchoolProfileTableList();
            lList = SchoolProfileTableManager.GetList();

            ddlSchool.DataSource = lList;
            ddlSchool.DataTextField = "SchoolName";
            ddlSchool.DataValueField = "SchoolKey";
            ddlSchool.DataBind();
        }


        public void LoadCityCodeDDL(DropDownList ddlCityCodeCode, string SelectItem)
        {
            CityCodeTableList lList = new CityCodeTableList();
            lList = CityCodeTableManager.GetList();

            ddlCityCodeCode.DataSource = lList;
            ddlCityCodeCode.DataTextField = "CityName";
            ddlCityCodeCode.DataValueField = "CityCode";
            ddlCityCodeCode.DataBind();

            //if (SelectItem.Equals(string.Empty))
            //{
            //    ddlCityCodeCode.SelectedValue = SelectItem;
            //}
        }

        public void LoadDayCodeDDL(DropDownList ddlDayCode, string SelectItem)
        {
            DayCodeTableList lList = new DayCodeTableList();
            lList = DayCodeTableManager.GetList();

            ddlDayCode.DataSource = lList;
            ddlDayCode.DataTextField = "Description";
            ddlDayCode.DataValueField = "DayCode";
            ddlDayCode.DataBind();
        }
    }
}